# -*- coding: utf-8 -*-

import math


def get_backbone_network_output_size(input_size,
                                     kernel_list=((7, 7), (3, 3), (3, 3), (3, 3)),
                                     stride_list=((2, 2), (2, 2), (2, 2), (2, 2)),
                                     padding_list=((3, 3), (1, 1), (1, 1), (1, 1))):
    """Get backbone network output size.

    Parameters
    ----------
    input_size : tuple
        input image height and width
    kernel_list : list of list of two elements
        kernel size(h_kernel, w_kernel) of the model layer where input size is not equal to output size
    stride_list : list of list of two elements
        stride size(h_stride, w_stride) of the model layer where input size is not equal to output size
    padding_list : list of list of two elements
        padding size(h_padding, w_padding) of the model layer where input size is not equal to output size

    Returns
    -------
    tuple :
        final output feature map size: height and width

    """
    assert len(kernel_list) == len(stride_list)
    assert len(stride_list) == len(padding_list)

    output_h, output_w = input_size
    for i in range(len(kernel_list)):
        h_k, w_k = kernel_list[i]
        h_p, w_p = padding_list[i]
        h_s, w_s = stride_list[i]
        output_h = math.floor(1.0 * (output_h + 2 * h_p - h_k) / h_s + 1)
        output_w = math.floor(1.0 * (output_w + 2 * w_p - w_k) / w_s + 1)
    return output_h, output_w


def main():
    pass


if __name__ == "__main__":
    main()
